package ${packageName}.view;

import com.jspx.sioc.annotation.Ref;
import com.jspx.txweb.support.ActionSupport;
import ${packageName}.env.*;
import ${packageName}.dao.*;
import ${packageName}.table.${className};

/**
 * Created by jspx.net maker
 * User: chenYuan
 * DateTime: ${date.string('yyyy-MM-dd HH:mm')}
 * Time: 18:11:39
 * ${packageName}.view.${className}
 * 提供页面显示正文
 */
@HttpMethod(caption = "${title}")
public class ${className}View  extends ActionSupport
{
    private ${className} ${className.firstLowerCase()} = null;
    public ${className}View()
    {

    }
   /**
    * DAO 载入入口
    */
    protected ${className}DAO ${className.firstLowerCase()}DAO;
    @Ref(name = ${namespace.firstUpperCase()}Ioc.${className.firstLowerCase()}DAO, namespace = ${namespace.firstUpperCase()}Ioc.namespace)
    public void set${className}DAO(${className}DAO ${className.firstLowerCase()}DAO)
    {
        this.${className.firstLowerCase()}DAO = ${className.firstLowerCase()}DAO;
    }


    private long id = 0;
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }

    public ${className} get${className}() throws Exception {
        if (${className.firstLowerCase()} != null &&${className.firstLowerCase()}.getId()!=0&&${className.firstLowerCase()}.getId()==id) return ${className.firstLowerCase()};
        return ${className.firstLowerCase()} = (${className}) ${className.firstLowerCase()}DAO.load(${className}.class,id);
    }

    /**
    * 清空本次运行缓存,当当前数据发生更新，修改动作的时候执行
    */
    public void clearData()
    {
        ${className.firstLowerCase()} = null;
    }

    /**
    * 清空本次运行缓存,当当前数据发生更新，修改动作的时候执行
    */
    public String execute() throws Exception
    {
        ${className.firstLowerCase()}  = get${className}();
        put("${className.firstLowerCase()}",${className.firstLowerCase()});
        return getActionResult();
    }
}